package com.wms_backend.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class VehicleComponent {

    @Autowired
    private MyWebSocketHandler myWebSocketHandler;
    @Autowired
    private InventoryWebSocketHandler inventoryWebSocketHandler;

    @KafkaListener(topics = "update-vehicle")
    public void listenUpdateVehicle(String message) throws InterruptedException {
        myWebSocketHandler.sendMessageToAll();
    }

    @KafkaListener(topics = "update-inventory")
    public void listenUpdateInventory(String message) throws InterruptedException {
        inventoryWebSocketHandler.sendMessageToAll(Integer.valueOf(message));
    }
}
